﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using DLV.Utilities;

namespace DLV.Data.Entities
{
    public class LanguageController
    {
        public int InsertLanguage(LanguageInfo info)
        {
            return SQL.InsertLanguage(info.LanguageName);
        }
        public void UpdateLanguage(LanguageInfo info)
        {
            SQL.UpdateLanguage(info.LanguageId, info.LanguageName);
        }
        public void DeleteLanguage(LanguageInfo info)
        {
            DeleteLanguage(info.LanguageId);
        }
        public void DeleteLanguage(int languageId)
        {
            SQL.DeleteLanguage(languageId);
        }
        public LanguageInfo GetLanguage(int languageId)
        {
            return CBO.FillObject<LanguageInfo>(SQL.GetLanguage(languageId));
        }
        public List<LanguageInfo> ListLanguage()
        {
            return CBO.FillCollection<LanguageInfo>(SQL.ListLanguage());
        }
        public DataTable SelectLanguage()
        {
            return CBO.ConvertToDataTable(ListLanguage(), typeof(LanguageInfo));
        }

        public Dictionary<object, object> ListLanguageLookup()
        {
            var pages = ListLanguage();
            var dicpages = new Dictionary<object, object>();
            foreach (var info in pages)
                dicpages.Add(info.LanguageId, info.LanguageName);
            return dicpages;
        }
    }
}
